/**
 * 权限工具类
 */
import store from '../store'

/**
 * 判断是否有权限
 * @param {String|Array} permission 权限标识
 * @returns {Boolean}
 */
export function hasPermission(permission) {
  const permissions = store.state.permissions
  if (!permissions || permissions.length === 0) {
    return false
  }
  
  if (typeof permission === 'string') {
    return permissions.includes(permission)
  } else if (permission instanceof Array && permission.length > 0) {
    return permission.some(item => permissions.includes(item))
  } else {
    return false
  }
}